﻿using CPPEI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SLG.Domain.Services
{
    public class UserService
    {
        public SingleResult<Entities.SYS_User> Get(string account, string password)
        {
            using(SLGDbContext dbContext = new SLGDbContext())
            {
                EntRep<Entities.SYS_User> rep = new EntRep<Entities.SYS_User>(dbContext);

                Entities.SYS_User user = rep.Get(p => p.Account == account && p.Password == password);
                if(user!=null)
                {
                    return new SingleResult<Entities.SYS_User>(user);
                }
                else
                {
                    return new SingleResult<Entities.SYS_User>(Library.ErrorCodes.User_NotExist);
                }
            }
        }
    }
}
